# -*- coding: utf-8 -*-
"""
# @Time    : 2017/12/25 11:19
# @Author  : wangqunsong
# @Email   : wangqunsong@hotmail.com
# @File    : bubbleSort.py
# @Software: PyCharm
"""
class BubbleSort(object):
    '''
    self.list:  要排序的list
    self.list_len: list的长度
    _sort(): 排序函数
    show():输出函数
    '''
    def __init__(self,list):       #初始化
        self.list = list
        self.list_len = len(list)

    def bubble_sort(self):
        for i in range(self.list_len - 1):
            currentStatus = False                     #用于判断是否发生了位置交换
            for j in range(self.list_len - 1 - i):
                if self.list[j] > self.list[j + 1]:
                    self.list[j],self.list[j + 1] = self.list[j + 1],self.list[j]
                    currentStatus = True
            if not currentStatus:
                break
        return self.list

    def show(self):
        print(self.bubble_sort())

if __name__ == '__main__':
    list_test = [3, 4, 1, 6, 2, 9, 7, 0, 8, 5,24,34,99,11,214]
    bubbleTest = BubbleSort(list_test)
    bubbleTest.show()

